<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box1 {
            width: 500px;
            height: 500px;
            background-color: blueviolet;
        }

        .box2 {
            width: 300px;
            height: 300px;
            background-color: burlywood;
        }

        .box3 {
            width: 100px;
            height: 100px;
            background-color: cadetblue;
        }
    </style>
</head>

<body>
    <div class="box1">
        box1
        <div class="box2">
            box2
            <div class="box3">box3</div>
        </div>
    </div>
    <script>
        const box1Ele = document.querySelector('.box1')
        const box2Ele = document.querySelector('.box2')
        const box3Ele = document.querySelector('.box3')

        box1Ele.onclick = function () {
            console.log("最外层 box1");
        }
        box2Ele.onclick = function (e) {
            console.log("中间层 box2");
        }
        box3Ele.onclick = function (e) {
            // e.stopPropagation();
            console.log("最内层 box3");
        }


        box1Ele.addEventListener('click', function () {
            console.log("最外层 box1");
        }, true)
        box2Ele.addEventListener('click', function () {
            console.log("中间层 box2");
        }, true)
        box3Ele.addEventListener('click', function () {
            console.log("最内层 box3");
        }, true)


    </script>
</body>

</html>